package com.heima.Config;

import com.heima.common.exception.RabbitMQcode;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SpringRabbitMQConfig {
//    声明交换机
    @Bean
    public FanoutExchange ArticlefanoutExchange()
    {
        return new FanoutExchange(RabbitMQcode.ArticleExchangeName);
    }

//    声明队列
    @Bean
    public Queue ArticlefanoutQueue()
    {
        return new Queue(RabbitMQcode.ArticleQueueName);
    }

//    绑定交换机和队列
    @Bean
    public Binding Articlebinding(Queue ArticlefanoutQueue,FanoutExchange ArticlefanoutExchange)
    {
        return BindingBuilder.bind(ArticlefanoutQueue).to(ArticlefanoutExchange);
    }

}
